package com.buyinglist.app.facade;

import java.util.List;
import java.util.LinkedList;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.buyinglist.app.DAO.GeoDAO;
import com.buyinglist.app.domain.City;
import com.buyinglist.app.domain.Country;
import com.buyinglist.app.domain.Region;
import com.buyinglist.app.view.CityView;
import com.buyinglist.app.view.CountryView;
import com.buyinglist.app.view.RegionView;
import com.buyinglist.app.web.Registration;

public class GeoFacade {

	private GeoDAO geoDAO;
	private static final Logger logger = LoggerFactory.getLogger(GeoFacade.class);

	public void setGeoDAO(GeoDAO geoDAO) {
		this.geoDAO = geoDAO;
	}
	
	public List<CountryView> findCountry(){
		logger.info("GeoFacade. Start findCountry");
		List<Country> cList=geoDAO.getlistCountry();
		List<CountryView> cvList=new LinkedList<CountryView>();
		for (Country c : cList){
			cvList.add(new CountryView(c));
		}
		return cvList;
	}
	
	public List<CountryView> findCountrybyprefix(String prefix){
		logger.info("GeoFacade. Start findCountrybyprefix");
		List<Country> cList=geoDAO.getlistCountrybypref(prefix);
		List<CountryView> cvList=new LinkedList<CountryView>();
		for (Country c : cList){
			cvList.add(new CountryView(c));
		}
		return cvList;
		
	}
	
	public List<RegionView> findRegion(){
		logger.info("GeoFacade. Start findRegion");
		List<Region> cList=geoDAO.getlistRegion();
		List<RegionView> cvList=new LinkedList<RegionView>();
		for (Region c : cList){
			cvList.add(new RegionView(c));
		}
		return cvList;
	}
	
	public List<RegionView> findRegionbyprefix(String prefix){
		logger.info("GeoFacade. Start findRegionbyprefix");
		List<Region> cList=geoDAO.getlistRegionbypref(prefix);
		List<RegionView> cvList=new LinkedList<RegionView>();
		for (Region c : cList){
			cvList.add(new RegionView(c));
		}
		return cvList;
		
	}

	public List<CityView> findCity(){
		logger.info("GeoFacade. Start findCity");
		List<City> cList=geoDAO.getlistCity();
		List<CityView> cvList=new LinkedList<CityView>();
		for (City c : cList){
			cvList.add(new CityView(c));
		}
		return cvList;
	}
	
	public List<CityView> findCitybyprefix(String prefix){
		logger.info("GeoFacade. Start findCitybyprefix");
		List<City> cList=geoDAO.getlistCitybypref(prefix);
		List<CityView> cvList=new LinkedList<CityView>();
		for (City c : cList){
			cvList.add(new CityView(c));
		}
		return cvList;
		
	}

	
}
